<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>用户管理</title>
        <link href="../../css/mine.css" type="text/css" rel="stylesheet">
        <script type="text/javascript" src="../../jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">

            /*1、异步联动查询部门角色信息*/
            $(function () {

                $("[name='deptId']").change(function () {

                   var deptId=$(this).val();
                   if (deptId==0){
                       alert("请您选择部门！")
                   } else {
                    $.ajax( {

                            url:"/resource/demo2/ajaxRequest",
                            type:"post",
                            data:"deptId="+deptId,
                            dataType:"json",
                            success:function (roleList) {
                                /*3、将jqery对象转换成js*/
                                $("#roleId")[0].length=0;
                                for (var i = 0; i <roleList.length ; i++) {
                                    //                               标签中显示的值          value值
                                    $("#roleId")[0].add(new Option(roleList[i].roleName,roleList[i].roleId));
                                }

                            },
                            error:function () {
                                alert("请求失败")
                            }

                    })
                   }
                })

            })

            /*2、ajax异步校验用户名*/


        </script>

    </head>

    <body>
        <div class="div_head">
            <span>
                <span style="float:left">当前位置是：-》资源管理》用户管理</span>
                <span style="float:right;margin-right: 8px;font-weight: bold">
                    <a style="text-decoration: none" href="/resource/demo2/list">【返回】</a>
                </span>
            </span>
        </div>
        <div></div>

        <div style="font-size: 13px;margin: 10px 5px">
            <form action="/resource/demo2/updateUserEmp" method="post" >
            <table border="1" width="100%" class="table_a">
                <tr>
                    <td width="120px;">用户编号<span style="color:red">*</span>：</td>
                    <td><input readonly type="text" name="id" value="${userEmp.id}" /></td>
                </tr>
                <tr>
                    <td>登录账号<span style="color:red">*</span>：</td>
                    <td>
                       <input readonly type="text" name="loginNumber" value="${userEmp.loginNumber}" />
                    </td>
                </tr>
               
                <tr>
                    <td>用户姓名<span style="color:red">*</span>：</td>
                    <td>
						<input required type="text" name="userName" value="${userEmp.userName}" /></td>
                </tr>
                <tr>
                    <td>密码<span style="color:red">*</span>：</td>
                    <td>
						<input required type="text" readonly name="password" value="${userEmp.password}" />
					</td>
                </tr>
                <tr>
                    <td>所属部门<span required style="color:red">*</span>：</td>
                    <td>

                        <select name="deptId">

                            <c:forEach items="${deptName}" var="name">
                                <option <c:if test="${userEmp.deptId==name.deptId}">selected</c:if> value="${name.deptId}" >${name.deptName}</option>
                            </c:forEach>

                        </select>
                    </td>
                </tr>
                <tr>
                    <td>所属职位<span required style="color:red">*</span>：</td>
                    <td>
                        <select id="roleId" name="roleId">
                            <c:forEach items="${userRoles}" var="roles">
                                <option value="${roles.roleId}" ${roles.deptId==userEmp.deptId?"selected":""}>${roles.roleName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>

				<tr>
                    <td>身份证<span required  style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="cardId" value="${userEmp.cardId}" />
                    </td>                
                </tr>

				<tr>
                    <td>联系电话<span style="color:red">*</span>：</td>
                    <td>
                        <input required type="text" name="userPhone" value="${userEmp.userPhone}"/>
                    </td>                
                </tr>

				<tr>
                    <td>邮箱<span style="color:red">*</span>：</td>
                    <td>
                        <input required type="text" name="userEmail" value="${userEmp.userEmail}" />
                    </td>                
                </tr>

				<tr>
                    <td>联系地址：</td>
                    <td>
                        <input required type="text" name="userAdress" value="${userEmp.userAdress}" />
                    </td>                
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit"  value="修改">
						<input type="reset" value="清空">
                    </td>
                </tr>  
            </table>
            </form>
        </div>
    </body>
</html>